using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Terra.Data.Entities.Identity;

namespace Terra.Data.Repository.Identity
{
    /// <summary>
    /// 权限仓储接口
    /// </summary>
    public interface IPermissionRepository : IRepository<Permission, Guid>
    {
        /// <summary>
        /// 根据菜单ID获取权限列表
        /// </summary>
        Task<List<Permission>> GetByMenuIdAsync(Guid menuId);

        /// <summary>
        /// 根据权限编码获取权限
        /// </summary>
        Task<Permission> GetByCodeAsync(string code);

        /// <summary>
        /// 批量创建权限
        /// </summary>
        Task<List<Permission>> CreatePermissionsAsync(List<Permission> permissions);

        /// <summary>
        /// 删除菜单关联的所有权限
        /// </summary>
        Task<bool> DeleteByMenuIdAsync(Guid menuId);

        /// <summary>
        /// 检查权限是否被角色使用
        /// </summary>
        Task<bool> IsPermissionInUseAsync(Guid permissionId);

        /// <summary>
        /// 批量更新权限
        /// </summary>
        Task<List<Permission>> UpdatePermissionsAsync(List<Permission> permissions);

        /// <summary>
        /// 获取用户权限码列表
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>权限码列表</returns>
        Task<List<string>> GetUserPermissionCodesAsync(Guid userId);

        /// <summary>
        /// 获取用户菜单权限列表
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>菜单列表</returns>
        Task<List<Menu>> GetUserMenusAsync(Guid userId);
    }
}
